import { test } from "node:test";
import { ACCESS_TOKEN } from "@/store/mutation-types.ts";
export default [
  {
    //获取加密key
    url: "/login/getEncryptedString",
    methods: "GET",
    response: () => {
      return {
        code: 200,
        data: {
          key: "0123456789ABHAEQ",
          iv: "DYgjCEIMVrj2W9xN",
        },
      };
    },
  },
  {
    //登录接口
    url: "/login/handleLogin",
    methods: "POST",
    response: (res: any) => {
      const { body } = res;
      console.log("res", res);
      const { username, password } = body;
      if (username != "test" || password != "W/wsYEclum4QgTqIgm7J/g==") {
        return {
          code: 500,
          message: "登录失败：用户名密码不正确",
        };
      }
      console.log("登录名：", username, "，密码：", password);
      return {
        code: 200,
        data: {
          token: "123456",
          username: username,
          nickname: "测试用户",
        },
        message: "登录成功",
      };
    },
  },
  {
    //退出接口
    url: "/login/handleLogout",
    methods: "POST",
    response: (res: any) => {
      const { headers } = res;
      console.log("ACCESS_TOKEN", ACCESS_TOKEN);
      const token = headers[ACCESS_TOKEN];
      if (!token || token == "") {
        return {
          code: 401,
          message: "token验证失败",
        };
      }
      return {
        code: 200,
        message: "退出成功",
      };
    },
  },
  {
    //获取菜单接口
    url: "/login/getMenu",
    methods: "POST",
    response: (res: any) => {
      const { headers } = res;
      console.log("ACCESS_TOKEN", ACCESS_TOKEN);
      const token = headers[ACCESS_TOKEN];
      if (!token || token == "") {
        return {
          code: 401,
          message: "token验证失败",
        };
      }
      console.log("token", token);
      return {
        code: 200,
        data: [
          {
            id: "1",
            parentid: "0",
            name: "首页",
            icon: "HomeFilled",
            url: "/home",
          },
          {
            id: "2",
            parentid: "0",
            name: "设备模块",
            icon: "Folder",
            children: [
              {
                id: "3",
                parentid: "2",
                name: "设备列表",
                icon: "Grid",
                url: "/dev/list",
              },
              {
                id: "4",
                parentid: "2",
                name: "导出分析",
                icon: "download",
                url: "/dev/export",
              },
            ],
          },
          {
            id: "5",
            parentid: "0",
            name: "地图模块",
            icon: "folder",
            children: [
              {
                id: "6",
                parentid: "5",
                name: "地图分析",
                icon: "MapLocation",
                url: "/map/analysis",
              },
            ],
          },
          {
            id: "7",
            parentid: "0",
            name: "远程遥测",
            icon: "promotion",
            url: "/remote/remoteCheck",
          },
        ],
      };
    },
  },
];
